package com.system.manager.modules.risk.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.system.manager.modules.authorized.entity.User;
import com.system.manager.modules.authorized.mapper.UserMapper;
import com.system.manager.modules.risk.dto.FlowVo;
import com.system.manager.modules.risk.entity.TbFlow;
import com.system.manager.modules.risk.mapper.TbFlowMapper;
import com.system.manager.modules.risk.service.ITbFlowService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author yxp
 * @since 2021-11-16
 */
@Service
public class TbFlowServiceImpl extends ServiceImpl<TbFlowMapper, TbFlow> implements ITbFlowService {

    @Autowired
    private UserMapper userMapper;
    @Autowired
    private TbFlowMapper tbFlowMapper;
    //上传业务
    @Override
    public void insertFlow(FlowVo flowVo) {
        TbFlow tbFlow = new TbFlow();


        tbFlow.setFName(flowVo.getFName());//业务名
        tbFlow.setRoleUser(flowVo.getRoleUser());//贾利博
        //获取用户角色
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("user_id",flowVo.getRoleUser());
        User user = userMapper.selectOne(wrapper);
        Integer role = user.getRole();//用户权限
        tbFlow.setFMessage(flowVo.getFMessage());
        tbFlow.setRole(role);
        Date date = new Date();
        tbFlow.setCreateTmie(date);
        tbFlowMapper.insert(tbFlow);
    }
}
